package org.afi.mushroomplayer.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.afi.mushroomplayer.model.SongInfo;


public class BaseUtils {

	public static String toSizeString(long size) {
		int sub_index = 0;
		String show = "";
		if (size >= 1073741824) {
			sub_index = (String.valueOf((float) size / 1073741824))
					.indexOf(".");
			show = ((float) size / 1073741824 + "000").substring(0,
					sub_index + 3) + "GB";
		} else if (size >= 1048576) {
			sub_index = (String.valueOf((float) size / 1048576)).indexOf(".");
			show = ((float) size / 1048576 + "000").substring(0, sub_index + 3)
					+ "M";
		} else if (size >= 1024) {
			sub_index = (String.valueOf((float) size / 1024)).indexOf(".");
			show = ((float) size / 1024 + "000").substring(0, sub_index + 3)
					+ "K";
		} else if (size < 1024) {
			show = String.valueOf(size) + "B";
		}
		return show;
	}

	public static String formatTime(int duration) {
		return ((duration / 1000 / 60) < 10 ? 
		        "0"	+ String.valueOf(duration / 1000 / 60) : 
		        String.valueOf(duration / 1000 / 60)) 
		        + ":" + 
		        ((duration / 1000 % 60) < 10 ? 
		        "0" + String.valueOf(duration / 1000 % 60) : 
		        String.valueOf(duration / 1000 % 60));
	}

}
